<template>
	<view>
		<cu-custom :isBack="true" bgColor="bg-white solids-bottom">
			<block slot="content">
				登录
			</block>
		</cu-custom>
		<view class="zai-box">
			<image src="../../static/logo3.png" mode='aspectFit' class="zai-logo"></image>
			<view class="zai-form">
				<uniInput :before="'请输入用户名'" :after="'用户名'" @blur="userBlurEvent" name="username"></uniInput>
				<uniInput :before="'请输入密码'" :after="'密码'" :password="true" @blur="pwdBlurEvent" name="password"></uniInput>
				<navigator url="../checking/index" class="zai-label">忘记密码？</navigator>
				<button class="zai-btn" @tap="login">登录</button>
				<navigator url="../register/register" hover-class="none" class="zai-label">还没有账号？点此注册.</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	import uniInput from '../../components/hnfly-input/uni-input.vue';
	export default {
		data() {
			return {
				username:"",
				password:""
			}
		},
		components: {
			uniInput
		},
		methods: {
			userBlurEvent(e){
				this.username = e.detail.value;
			},
			pwdBlurEvent(e){
				this.password = e.detail.value;
			},
			login() {
				let data = {
					Account:this.username,
					Password:this.password
				}
				uni.request({
					url: this.AjaxUrl+'/Account/HPLogin',
					method:"POST",
					data:data,
					success: (res) => {
						if (res.statusCode == 200) {
							console.info(JSON.parse(res.data.Extend));
							uni.setStorage({
								key: 'user',
								data: JSON.parse(res.data.Extend),
								success: function() {
									console.log('3success');
									uni.showToast({
										icon: 'none',
										title: "登陆成功",
										// #ifdef MP-WEIXIN
										duration: 2000,
										// #endif
										// mask: true
									});
									uni.reLaunch({url:"/pages/tabindex/my/my"});
								}
							});
						}
					},
					fail:function(e){
						console.info("报错了",e);
					}
				});
			}
		}
	}
</script>

<style>
	.zai-box{
		padding: 0 100upx;
		position: relative;
	}
	.zai-logo{
		width: 100%;
		height: 144upx;
		margin-top: 100upx;
	}
	.zai-title{
		position: absolute;
		top: 0;
		line-height: 360upx;
		font-size: 68upx;
		color: #fff;
		text-align: center;
		width: 100%;
		margin-left: -100upx;
	}
	.zai-form{
		margin-top: 100upx;
	}
	.zai-label{
		padding: 60upx 0;
		text-align: center;
		font-size: 30upx;
		color: #a7b6d0;
	}
	.zai-btn{
		background: #ff7777;
		color: #fff;
		border: 0;
		border-radius: 100upx;
		font-size: 36upx;
	}
	.zai-btn:after{
		border: 0;
	}
	/*按钮点击效果*/
	.zai-btn.button-hover{
		transform: translate(1upx, 1upx);
	}
</style>
